package reflect;

import java.lang.reflect.Method;

public class ReflectDemo7 {
    public static void main(String[] args) throws Exception{
        Person p = new Person();
        System.out.println(p);
        p.setAge(55);
        System.out.println(p);
        Class<?> aClass = Class.forName("reflect.Person");
        Object o = aClass.newInstance();
        System.out.println(o);

        Method method = aClass.getMethod("setName", String.class);
        method.invoke(o,"lisi");
        System.out.println(o);
    }
}
